package com.se.web.tags;

import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;

public class PagingTag extends BodyTagSupport
{
  private static final long serialVersionUID = 6051084664833393851L;
  private String paramName = "curPage";
  private int totalCount;
  private int curPage;
  private int listPages;
  private int listLines = 10;
  private String prevImage = "";
  private String nextImage = "";
  private String splitImage = "";
  private String alinkCss = "";
  private String curPageCss = "";
  private String textCss = "";
  private String listUrl = "";

  public void setTotalCount(int paramInt)
  {
    this.totalCount = paramInt;
  }

  public void setAlinkCss(String paramString)
  {
    this.alinkCss = paramString;
  }

  public void setCurPage(int paramInt)
  {
    this.curPage = paramInt;
  }

  public void setCurPageCss(String paramString)
  {
    this.curPageCss = paramString;
  }

  public void setListUrl(String paramString)
  {
    this.listUrl = paramString;
  }

  public void setSplitImage(String paramString)
  {
    this.splitImage = paramString;
  }

  public void setNextImage(String paramString)
  {
    this.nextImage = paramString;
  }

  public void setListLines(int paramInt)
  {
    this.listLines = paramInt;
  }

  public void setListPages(int paramInt)
  {
    this.listPages = paramInt;
  }

  public void setPrevImage(String paramString)
  {
    this.prevImage = paramString;
  }

  public void setTextCss(String paramString)
  {
    this.textCss = paramString;
  }

  public void setParamName(String paramString)
  {
    this.paramName = paramString;
  }

  public int doStartTag()
    throws JspTagException
  {
    StringBuffer localStringBuffer = new StringBuffer();
    String str = "&";
    if (this.listUrl.indexOf("?") < 0)
      str = "?";
    try
    {
      int i = (this.totalCount - 1) / this.listLines + 1;
      int j = (this.curPage - 1) / this.listPages * this.listPages + 1;
      if (j > this.listPages)
      {
        localStringBuffer.append("<a href=\"").append(this.listUrl).append(str).append(this.paramName).append("=").append(j - 1).append("\"");
        if (this.alinkCss.length() > 0)
          localStringBuffer.append(" class=\"").append(this.alinkCss).append("\">");
        else
          localStringBuffer.append(">");
        if (this.textCss.length() > 0)
          localStringBuffer.append("<font class=\"").append(this.textCss).append("\">");
        if (this.prevImage.length() > 0)
          localStringBuffer.append(this.prevImage);
        else
          localStringBuffer.append("[Prev]&nbsp;");
        if (this.textCss.length() > 0)
          localStringBuffer.append("</font>");
        localStringBuffer.append("</a>");
      }
      else
      {
        if (this.textCss.length() > 0)
          localStringBuffer.append("<font class=\"").append(this.textCss).append("\">");
        if (this.prevImage.length() > 0)
          localStringBuffer.append(this.prevImage);
        else
          localStringBuffer.append("[Prev]&nbsp;");
        if (this.textCss.length() > 0)
          localStringBuffer.append("</font>");
      }
      int k = 0;
      for (int m = 0; m < this.listPages; m++)
      {
        k = j + m;
        if (k <= i)
        {
          if (k == this.curPage)
          {
            localStringBuffer.append("<span ");
            if (this.curPageCss.length() > 0)
              localStringBuffer.append(" class=\"").append(this.curPageCss).append("\">");
            else
              localStringBuffer.append(">");
            localStringBuffer.append(k);
            localStringBuffer.append("</span>");
          }
          else
          {
            localStringBuffer.append("<a href=\"").append(this.listUrl).append(str).append(this.paramName).append("=").append(k).append("\"");
            if (this.alinkCss.length() > 0)
              localStringBuffer.append(" class=\"").append(this.alinkCss).append("\">");
            else
              localStringBuffer.append(">");
            localStringBuffer.append(k);
            localStringBuffer.append("</a>");
          }
          if (this.splitImage.length() > 0)
          {
            if (m + 1 < this.listPages)
              localStringBuffer.append(this.splitImage);
          }
          else if (m + 1 < this.listPages)
            localStringBuffer.append("&nbsp;");
        }
      }
      if (i > k)
      {
        localStringBuffer.append("<a href=\"").append(this.listUrl).append(str).append(this.paramName).append("=").append(k + 1).append("\"");
        if (this.alinkCss.length() > 0)
          localStringBuffer.append(" class=\"").append(this.alinkCss).append("\">");
        else
          localStringBuffer.append(">");
        if (this.textCss.length() > 0)
          localStringBuffer.append("<font class=\"").append(this.textCss).append("\">");
        if (this.nextImage.length() > 0)
          localStringBuffer.append(this.nextImage);
        else
          localStringBuffer.append("&nbsp;[Next]");
        if (this.textCss.length() > 0)
          localStringBuffer.append("</font>");
        localStringBuffer.append("</a>");
      }
      else
      {
        if (this.textCss.length() > 0)
          localStringBuffer.append("<font class=\"").append(this.textCss).append("\">");
        if (this.nextImage.length() > 0)
          localStringBuffer.append(this.nextImage);
        else
          localStringBuffer.append("&nbsp;[Next]");
        if (this.textCss.length() > 0)
          localStringBuffer.append("</font>");
      }
      JspWriter localJspWriter = this.pageContext.getOut();
      localJspWriter.print(localStringBuffer.toString());
    }
    catch (Exception localException)
    {
      throw new JspTagException(localException.toString());
    }
    return 0;
  }
}

/* Location:           D:\DevApp\workspace\DevKsnetWeb9.3\WebContent\WEB-INF\lib\netville-2.2.3.jar
 * Qualified Name:     netville.web.tags.PagingTag
 * JD-Core Version:    0.6.2
 */